<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="springform"
	uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@	taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="/WEB-INF/views/webPartBiz/head.jsp"></jsp:include>
<title>文章管理 - 呵Sever</title>

</head>
<body>
	<jsp:include page="/WEB-INF/views/webPartBiz/top.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/views/webPartBiz/left.jsp"></jsp:include>
	<div class="mycol col-md-11 col-xs-11">
		<div class="main">
			<div class="mainItem">
				<h3>文章管理</h3>
				<ul class="nav nav-tabs">
					<li class="active" id="listTab"><a
						href="javascript:showTab('list')">列表</a></li>
					<li id="createTab"><a href="javascript:showTab('create')">发表</a>
					</li>
				</ul>
				<div id="list">
				<table class="table table-hover">
					<colgroup>
						<col width="30%" />
						<col width="5%" />
						<col width="5%" />
						<col width="" />
						<col width="" />
						<col width="10%" />
					</colgroup>
					<thead>
						<tr>
							<th>标题</th>
							<th>热度</th>
							<th>评论</th>
							<th>发表时间</th>
							<th>修改时间</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${page.content }" var="item">
						<tr>
							<td>${item.title }</td>
							<td>${item.hot }℃</td>
							<td>${item.reviewNum }</td>
							<td>
							<fmt:formatDate value="${item.createDate }" pattern="yyyy/MM/dd HH:mm:ss"/>
							</td>
							<td>
							<fmt:formatDate value="${item.updateDate }" pattern="yyyy/MM/dd HH:mm:ss"/></td>
							<td>
								<a href="" target="_blank" title="详情" class="glyphicon glyphicon-search"></a>
								<a href="" title="修改标签" class="glyphicon glyphicon-tag"></a>
								<a href="javascript:;" title="删除" itemTitle="${item.title }" itemId="${item.id }" class="glyphicon glyphicon-remove deleteButton"></a>
							</td>
						</tr>
						</c:forEach>
					</tbody>
				</table>
				<jsp:include page="/WEB-INF/views/webPartBiz/page.jsp"></jsp:include>
				</div>
				
				
				<springform:form modelAttribute="article"
					action="${context }/biz/article/add" method="post" id="create"
					style="display:none;">
					<br>
					<div class="title">
						标题：<input type="text" name="title" placeholder="请输入标题">
					</div>
					<div class="articleMain">
						<textarea name="content" style="visibility: hidden;"></textarea>
					</div> 
					标签：
					<div style="overflow: auto;">
						<c:forEach items="${tags }" var="item">
							<c:if test="${item.parentTag == null }">
								<div class="tree show">
									<ul>
										<li><span class="tag"> ${item.name } </span> <input
											type="checkbox" name="tagIds" value="${item.id }"> <c:if
												test="${fn:length(item.childTags)!=0 }">
												<ul>
													<c:forEach items="${item.childTags }" var="child">
														<li><span class="tag"> ${child.name } </span> <input
															type="checkbox" name="tagIds" value="${child.id }">
															<c:if test="${fn:length(child.childTags)!=0 }">
																<ul>
																	<c:forEach items="${child.childTags }" var="grandChild">
																		<li><span class="tag"> ${grandChild.name }
																		</span> <input type="checkbox" name="tagIds"
																			value="${grandChild.id }"></li>
																	</c:forEach>
																</ul>
															</c:if></li>
													</c:forEach>
												</ul>
											</c:if></li>
									</ul>
								</div>
							</c:if>
						</c:forEach>
					</div>
					<div>
						<button class="btn btn-default">保存</button>
					</div>
				</springform:form>
			</div>
		</div>
	</div>
	<jsp:include page="/WEB-INF/views/webPartBiz/right.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/views/webPartBiz/footer.jsp"></jsp:include>
</body>
</html>

<script>
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="content"]', {
			width : '100%',
			height : '300px',
			resizeType : 0,
			allowPreviewEmoticons : false,
			allowImageUpload : false,
		});
	});

	function showTab(item) {
		$("#list").hide();
		$("#listTab").attr("class", "");
		$("#create").hide();
		$("#createTab").attr("class", "");

		$("#" + item).show();
		$("#" + item + "Tab").attr("class", "active");
	}
	$(function(){
		$('.deleteButton').click(function(){
			var id = $(this).attr("itemId");
			var title = $(this).attr("itemTitle");
			$confirm = $('.modal#confirm');
			$confirm.find(".modal-title").html("确认删除");
			$confirm.find(".modal-body").html("确认删除文章【"+title+"】？");
			$confirm.find(".modal-ok").attr("href","${context }/biz/article/del/"+id);
			$confirm.modal('show');
		});
		
	});
</script>